<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>123321</title>
    <style>
        body {
            height: 3000px;
            width: 3000px;
        }

        span {
            display: block;
            position: fixed;
            right: 5px;
            bottom: 10px;
            background-color: aqua;
            line-height: 20px;
            padding: 5px;
        }
    </style>
</head>

<body>
    <span>
        回到顶部哦
    </span>
    <SCRIPT>

        var span = document.getElementsByTagName('span')[0]
        var timer = null
        span.onclick = function () {
            clearInterval(timer)
            timer = setInterval(function () {
                document.documentElement.scrollTop -= 40
                document.documentElement.scrollLeft -= 50
                if (document.documentElement.scrollTop <= 0 && document.documentElement.scrollLeft <= 0) {
                    clearInterval(timer)
                }
            }, 10)
        }
        // window.onscroll = function () {
        //     console.log(document.documentElement.scrollTop)
        //     console.log(document.documentElement.scrollLeft)
        // }






























































             // console.log(document.title)
        // console.log(document.documentElement)
        // console.log('--------------------------------------------------------------')
        // console.log(document.head)
        // console.log(location.pathname)
        /*-------------------------------------------------------------------------------------------------------------------------------*/
    </SCRIPT>
</body>

</html>